﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharePointEnforcer.Rules
{
    /// <summary>
    /// Checks to make sure that the sites use explicit permissions
    /// </summary>
    public class ForceExplicitSecurity : EnforcerRuleBase
    {
        public override void Evaluate(EnforcerArg pArg)
        {
            pArg.Result = EnforcerEvaluateResult.Ignore;

            // this check does not apply for the root web
            if (!pArg.Web.IsRootWeb)
            {
                if (pArg.Web.HasUniqueRoleDefinitions)
                    pArg.Result = EnforcerEvaluateResult.Pass;
                else
                    pArg.Result = EnforcerEvaluateResult.Fail;
            }
        }
    }
}
